package com.briup.es.web;

import com.briup.es.config.response.Result;
import com.briup.es.domain.vo.BookVO;
import com.briup.es.service.CollectService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/collect")
@RequiredArgsConstructor
public class CollectController {

    private final CollectService collectService;

    @GetMapping
    public Result<List<BookVO>> listCollect() {
        List<BookVO> bookVOS = collectService.listCollect();
        return Result.success(bookVOS);
    }

    @PostMapping("/{bookId}")
    public Result<?> addCollect(@PathVariable Integer bookId){
        collectService.addCollect(bookId);
        return Result.success();
    }

    @DeleteMapping
    public Result<?> cancelCollect(@RequestBody List<Integer> ids){
        collectService.batchCancelCollect(ids);
        return Result.success();
    }
}
